package com.lindroid.materialdesigndemo.bottomsheetdemo;

import android.os.Bundle;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.lindroid.materialdesigndemo.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author linyulong
 * BottomSheet出现时空白的地方是不会变成
 */
public class BottomSheetActivity extends AppCompatActivity {
    @Bind(R.id.bottom_sheet)
    LinearLayout bottomSheet;
    private BottomSheetBehavior bottomSheetBehavior;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bottom_sheet);
        ButterKnife.bind(this);
        bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
        TextView tvBlue = (TextView) bottomSheet.findViewById(R.id.tv_blue);
        tvBlue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(BottomSheetActivity.this, "这是一个蓝色", Toast.LENGTH_SHORT).show();
            }
        });
    }

    @OnClick({R.id.btn_show_sheet, R.id.btn_hide_sheet, R.id.btn_peek_height})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_show_sheet:
                //完全展开
                bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                break;
            case R.id.btn_hide_sheet:
                //完全隐藏
                bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
                break;
            case R.id.btn_peek_height:
                //显示peekHeight的高度
                bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
                break;
            default:
                break;
        }
    }
}
